﻿using MQTTnet.Client.Options;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace util_c_sharp.util.mqtt
{
    internal class FactoryMqttOption
    {
        public static IMqttClientOptions InitOptionsOfNtd()
        {
            return InitOptions("121.40.237.31", 31883, "admin", "public");
        }
        public static IMqttClientOptions InitOptionsOfFm()
        {
            return InitOptions("106.55.93.45", 1883, "emqx", "public");
        }

        static IMqttClientOptions InitOptions(string url, int port, string username, string password)
        {
            int randomInt = new Random().Next(1, 100000);
            var options = new MqttClientOptionsBuilder()
                .WithClientId("ntd-client-" + randomInt)
                .WithTcpServer(url, port)
                .WithCredentials(username, password)
                .WithCleanSession()
                .Build();
            return options;
        }
    }
}
